// 4. Invoker（调用者：遥控器）
/// <summary>
/// 遥控器
/// </summary>
public class RemoteControl
{
  private ICommand _command;
  private ICommand _lastCommand; // 用于撤销

  public void SetCommand(ICommand command)
  {
    _command = command;
  }

  public void PressButton()
  {
    _command.Execute();
    _lastCommand = _command;
  }

  public void PressUndo()
  {
    _lastCommand?.Undo();
  }
}